package com.xueyi.system.traceabilityCode.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xueyi.common.core.constant.basic.SqlConstants;
import com.xueyi.system.traceabilityCode.domain.po.TraceabilityCodePo;
import com.xueyi.system.traceabilityCode.domain.query.TraceabilityCodeQuery;
import com.xueyi.system.traceabilityCode.domain.dto.TraceabilityCodeDto;
import com.xueyi.system.traceabilityCode.mapper.TraceabilityCodeMapper;
import com.xueyi.system.traceabilityCode.service.ITraceabilityCodeService;
import com.xueyi.system.traceabilityCode.manager.ITraceabilityCodeManager;
import com.xueyi.common.web.entity.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 溯源码管理管理 服务层处理
 *
 * @author zlf
 */
@Service
public class TraceabilityCodeServiceImpl extends BaseServiceImpl<TraceabilityCodeQuery, TraceabilityCodeDto, ITraceabilityCodeManager> implements ITraceabilityCodeService {


    @Autowired
    private TraceabilityCodeMapper traceabilityCodeMapper;
    /**
     * 查询溯源码管理对象列表 | 数据权限 | 附加数据
     *
     * @param traceabilityCode 溯源码管理对象
     * @return 溯源码管理对象集合
     */
    @Override
    //@DataScope(userAlias = "createBy", mapperScope = {"TraceabilityCodeMapper"})
    public List<TraceabilityCodeDto> selectListScope(TraceabilityCodeQuery traceabilityCode) {
        return baseManager.selectListExtra(traceabilityCode);
    }

    @Override
    public TraceabilityCodePo getTraceabilityCodePoInfo(String code) {
        QueryWrapper<TraceabilityCodePo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("code",code);
        queryWrapper.last(SqlConstants.LIMIT_ONE);
        TraceabilityCodePo traceabilityCodePos = traceabilityCodeMapper.selectOne(queryWrapper);
        return traceabilityCodePos;
    }
}
